package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.VipPrice;
import cn.source.system.service.IVipPriceService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * vip价格Controller
 *
 * @author sourcebyte.vip
 * @date 2025-05-31
 */
@RestController
@RequestMapping("/system/vipPrice")
public class VipPriceController extends BaseController
{
    @Autowired
    private IVipPriceService vipPriceService;

    /**
     * 查询vip价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:vipPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(VipPrice vipPrice)
    {
        startPage();
        List<VipPrice> list = vipPriceService.selectVipPriceList(vipPrice);
        return getDataTable(list);
    }

    /**
     * 获取vip价格详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vipPriceService.selectVipPriceById(id));
    }

    /**
     * 新增vip价格
     */
    @PreAuthorize("@ss.hasPermi('system:vipPrice:add')")
    @Log(title = "vip价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VipPrice vipPrice)
    {
        return toAjax(vipPriceService.insertVipPrice(vipPrice));
    }

    /**
     * 修改vip价格
     */
    @PreAuthorize("@ss.hasPermi('system:vipPrice:edit')")
    @Log(title = "vip价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VipPrice vipPrice)
    {
        return toAjax(vipPriceService.updateVipPrice(vipPrice));
    }

    /**
     * 删除vip价格
     */
    @PreAuthorize("@ss.hasPermi('system:vipPrice:remove')")
    @Log(title = "vip价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vipPriceService.deleteVipPriceByIds(ids));
    }

    /**
     * 导出vip价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:vipPrice:export')")
    @Log(title = "vip价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VipPrice vipPrice)
    {
        List<VipPrice> list = vipPriceService.selectVipPriceList(vipPrice);
        ExcelUtil<VipPrice> util = new ExcelUtil<VipPrice>(VipPrice.class);
        util.exportExcel(response, list, "vip价格数据");
    }
}
